#include "MessageSystemComponent.h"
#include "../EngineInstance.h"

MessageSystemComponent::MessageSystemComponent(EngineInstance* engine)
{
	_Engine = engine;
	_Messages.ClearList();
}
MessageSystemComponent::~MessageSystemComponent()
{
	_Messages.ClearList();
}

/// Purpose:	Processes all the messages in the queue and clears the list.
void MessageSystemComponent::ProcessMessages()
{
	size_t Count = _Messages.Size();
	while( Count > 0 )
	{
		int MD = _Messages.Front();
		_Engine->HandleMessage(MD);
		_Messages.RemoveFromList(MD);
		--Count;
	}

}

/// Purpose:	Adds a message to the queue for processing.
void MessageSystemComponent::AddMessage(int Message)
{
	_Messages.AddToList(Message);
}